package com.sun.j2ee.blueprints.servicelocator;

import javax.naming.InitialContext;
import javax.naming.NamingException;

import org.aspectj.lang.SoftException;

public aspect ExceptionWrapping issingleton(){

	declare soft : NamingException : 
		(call (* InitialContext.*(..) throws NamingException )
		|| call (InitialContext.new(..) throws NamingException ))
		&& within (BaseServiceLocator);

	pointcut trowers() : 
		(execution(* *.*(..)   throws ServiceLocatorException )
	  || execution(*.*.new(..) throws ServiceLocatorException)) 
	&& within (BaseServiceLocator) ;
	
	after() throwing (SoftException ex) throws ServiceLocatorException
		: trowers() {
		throw new ServiceLocatorException(ex.getWrappedThrowable());
	}

}
